-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sparse merkle tree part1 #58
Conversation
trie/constants.py
Outdated
from eth_hash.auto import keccak | ||
EMPTY_LEAF_NODE_HASH = BLANK_HASH | ||
EMPTY_NODE_HASHES = [EMPTY_LEAF_NODE_HASH] | ||
for _ in range(159): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As 160 (and 159) is used a couple of times, it would make sense to make it a constant. Maybe NODE_BIT_LENGTH
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, what do you think about maybe something more straight forward like TREE_HEIGHT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TREE_HEIGHT
sounds good
trie/sparse_merkle_tree.py
Outdated
target_bit >>= 1 | ||
|
||
if self.db[node_hash] is b'': | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reason for returning None
instead of raising a KeyError
? We've found that return value checking is way easier to forget than exception handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason. Just that in hexary trie, BLANK_NODE
is returned for non-existent key. Raising an exception does make more sense.
@pipermerriam Updated the behavior for handling non-existent key and ready for review again. |
Update template
What was wrong?
Try out Sparse Merkle Tree for sharding research.
How was it fixed?
Implement Sparse Merkle Tree as described in #37.
Cute Animal Picture